/*
  File: RolePermissionMapEntity.cs
  Author: rcrxy
  CreateTime: 2025/06/26 18:48

  Description:
*/

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace StudentVideo.Data.Entities;

/// <summary>
/// 角色 - 权限 映射表
/// </summary>
[Table("role_permission_map")]
[Index(nameof(RoleId))]
[Index(nameof(PermissionId))]
[PrimaryKey(nameof(RoleId), nameof(PermissionId))]
public class RolePermissionMapEntity {

   /// <summary>
   /// 角色 id
   /// </summary>
   [Required]
   [MaxLength(50)]
   public required string RoleId { get; set; }

   [ForeignKey(nameof(RoleId))]
   public required RoleEntity Role { get; set; }

   /// <summary>
   /// 权限 id
   /// </summary>
   [Required]
   [MaxLength(50)]
   public required string PermissionId { get; set; }

   [ForeignKey(nameof(PermissionId))]
   public required PermissionEntity Permission { get; set; }
}
